package com.heihx.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heihx.entity.DishFlavor;
import com.heihx.mapper.DishFlavorMapper;
import com.heihx.service.DishFlavorService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DishFlavorServiceImpl extends ServiceImpl<DishFlavorMapper, DishFlavor> implements DishFlavorService {
    @Override
    public void removeBatchByDishIds(List<Long> ids) {
        List<Long> flavorIds = lambdaQuery()
                .select(DishFlavor::getId)
                .in(DishFlavor::getDishId, ids)
                .list()
                .stream().map(DishFlavor::getId).toList();

        removeBatchByIds(flavorIds);
    }

    @Override
    public List<DishFlavor> getByDishId(Long id) {
        return lambdaQuery()
                .eq(DishFlavor::getDishId, id)
                .list();
    }
}
